# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libwebp

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.0
pkgrel=2
pkgdesc="the WebP library. Includes conversion tools. (mingw-w64)"
arch=('any')
url="https://code.google.com/p/webp/"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-libpng" "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo" "${MINGW_PACKAGE_PREFIX}-libtiff" "${MINGW_PACKAGE_PREFIX}-giflib")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=(http://webp.googlecode.com/files/$_realname-$pkgver.tar.gz
        giflib.patch)
sha1sums=('326c4b6787a01e5e32a9b30bae76442d18d2d1b6'
          'e8e78cf2b7161982397ca40ad1b75a2f3323bfd4')

prepare() {
  cd $srcdir/$_realname-$pkgver
  patch -p1 -i ${srcdir}/giflib.patch
}

build() {
  mkdir -p $srcdir/$MINGW_CHOST
  cd "$srcdir/$MINGW_CHOST"
  ../$_realname-$pkgver/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --enable-swap-16bit-csp \
    --enable-experimental \
    --enable-libwebpmux \
    --enable-libwebpdemux \
    --enable-libwebpdecoder
  make
}

package() {
  cd "$srcdir/$MINGW_CHOST"
  make install DESTDIR="${pkgdir}"
  rm -r "${pkgdir}${MINGW_PREFIX}/share"
}
